package mumethod;

import java.sql.Date;

import muobject.Physical;
import muobject.School;

public class ValidFunction {

	public boolean DateFormat(String datestr) {
		try {
			@SuppressWarnings("unused")
			Date date = Date.valueOf(datestr);
			return true;
		} catch (Exception e) {
			return false;
		}
	}

	public boolean IntFormat(String intstr) {
		try {
			@SuppressWarnings("unused")
			int integer = Integer.valueOf(intstr);
			return true;
		} catch (Exception e) {
			return false;
		}
	}
	
	public boolean StringEmpty(String str) {
		try {
			if (!str.equals("")) {
				return true;
			} else {
				return false;
			}
		} catch (Exception e) {
			return false;
		}
	}
	
	public double doubleReturn(String doublestr){
		try {
			double doubleReturn = Double.valueOf(doublestr);
			return doubleReturn;
		} catch (Exception e) {
			return 0.0;
		}
	}

	public String SchoolDataValid(School school) {
		if(!StringEmpty(school.getSno()))
			return "Sno";
		else
			return "";
	}
	
	public Physical PhysicalNullReturn(Physical phsyical){
		if (phsyical == null){
			return new Physical(0, "", "", null,
					0, 0, 0, 0,
					0, 0, 0, 0, "",
					null, null);
		}else{
			return phsyical;
		}
	}
}
